﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Excersises
{
    class Fraction : IFormattable
    {
        private int nominator;
        private int denominator;

        public Fraction(int nominator, int denominator)
        {
            this.nominator = nominator;
            this.denominator = denominator;
        }

        public int Nominator
        {
            get
            {
                return nominator;
            }
            set
            {
                nominator = value;
            }
        }

        public int Denominator
        {
            get
            {
                return denominator;
            }
            set
            {
                denominator = value;
            }
        }

        public string ToString(string format, IFormatProvider formatProvider)
        {
            switch (format)
            {
                case null:
                    return (double)nominator / denominator + "";
                case "N":
                    return String.Format("{0}/{1}", nominator, denominator);
                case "R":
                    return String.Format("{0:F}", (double)nominator / denominator);
                default:
                    throw new ArgumentException("Unknown format {0}", format);
            }
        }
    }
}
